package com.tudouji.project.customer.service.impl;

import com.tudouji.common.utils.DateUtils;
import com.tudouji.common.utils.IdUtils;
import com.tudouji.common.utils.SecurityUtils;
import com.tudouji.project.customer.domain.Addresrecord;
import com.tudouji.project.customer.mapper.AddresrecordMapper;
import com.tudouji.project.customer.service.IAddresrecordService;
import com.tudouji.project.system.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 地址记录Service业务层处理
 *
 * @author tudouji
 * @date 2022-09-29
 */
@Service
public class AddresrecordServiceImpl implements IAddresrecordService
{
    @Autowired
    private AddresrecordMapper addresrecordMapper;

    /**
     * 查询地址记录
     *
     * @param guid 地址记录ID
     * @return 地址记录
     */
    @Override
    public Addresrecord selectAddresrecordById(String guid)
    {
        return addresrecordMapper.selectAddresrecordById(guid);
    }

    /**
     * 查询地址记录列表
     *
     * @param addresrecord 地址记录
     * @return 地址记录
     */
    @Override
    public List<Addresrecord> selectAddresrecordList(Addresrecord addresrecord)
    {
        return addresrecordMapper.selectAddresrecordList(addresrecord);
    }
    @Override
    public List<Addresrecord> selectAddresrecordListByCustomer(String customerid)
    {
        return addresrecordMapper.selectAddresrecordListByCustomer(customerid);
    }

    /**
     * 新增地址记录
     *
     * @param addresrecord 地址记录
     * @return 结果
     */
    @Override
    public int insertAddresrecord(Addresrecord addresrecord)
    {
        SysUser sysUser = SecurityUtils.getLoginUser().getUser();
        addresrecord.setGuid(IdUtils.fastSimpleUUID());
        addresrecord.setOperatorid(sysUser.getTuserId());
        addresrecord.setCreateTime(DateUtils.getNowDate());
        addresrecord.setType(1);
        return addresrecordMapper.insertAddresrecord(addresrecord);
    }

    /**
     * 修改地址记录
     *
     * @param addresrecord 地址记录
     * @return 结果
     */
    @Override
    public int updateAddresrecord(Addresrecord addresrecord)
    {
        return addresrecordMapper.updateAddresrecord(addresrecord);
    }

    /**
     * 批量删除地址记录
     *
     * @param guids 需要删除的地址记录ID
     * @return 结果
     */
    @Override
    public int deleteAddresrecordByIds(String[] guids)
    {
        return addresrecordMapper.deleteAddresrecordByIds(guids);
    }

    /**
     * 删除地址记录信息
     *
     * @param guid 地址记录ID
     * @return 结果
     */
    @Override
    public int deleteAddresrecordById(String guid)
    {
        return addresrecordMapper.deleteAddresrecordById(guid);
    }
}
